<?php
    class Default_Model_Image extends Zend_Db_Table_Abstract
    {
        protected $_db;
		
		public function __construct()
		{
			$this->_db = Zend_Registry::get('db');
		}
        
        public function getItem($type, $hotel_id, $locale)
        {
            $image = array(
                'id',
                'image',
            );
            $image_language = array(
                'name',
            );
            $sql = $this->_db->select()
                            ->from('image AS i', $image)
                            ->join('image_language AS il', 'il.image_id = i.id', $image_language)
                            ->join('language AS l', 'l.id = il.language_id', null)
                            ->where('i.type = ?', $type)
                            ->where('i.hotel_id = ?', $hotel_id)
                            ->where('i.status = 1')
                            ->where('l.locale = ?', $locale)
                            ->order('i.id DESC');
            $result = $this->_db->fetchAll($sql);
            return $result;
        }
    }
